package com.situ.day21;

import org.junit.Test;

import java.lang.reflect.Method;
import java.util.Arrays;

//@Author("男")
//@Author(value = "男")
//@Author(value = {"男", "女"})
@Author(name = "zhang", age = 23,value = {"男", "女"})
public class AuthorDemo {

    @Author(name = "zhangsan", age = 24, value = "男")
    public void add() {

    }

    @Test
    public void test1() throws NoSuchMethodException {
        Class<AuthorDemo> clazz = AuthorDemo.class;
        Author typeAuthor = clazz.getAnnotation(Author.class);
        System.out.println(typeAuthor.name());
        System.out.println(typeAuthor.age());
        System.out.println(typeAuthor.value()[0]);
        System.out.println(Arrays.toString(typeAuthor.value()));

        Method method = clazz.getMethod("add");
        Author methodAuthor = method.getAnnotation(Author.class);
        System.out.println(methodAuthor.name());
        System.out.println(methodAuthor.age());
        System.out.println(methodAuthor.value()[0]);
        System.out.println(Arrays.toString(methodAuthor.value()));
    }
}
